package com.lcj.dao;

import com.lcj.model.CompanyRecruitInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by yhl on 2018/9/11.
 */
@Repository
public interface CompanyRecruitInfoDao {

    @Insert("INSERT INTO `t_zzjob_company` (company_name,recruit_name, industry_name, persons, work_place, recruit_url,create_time,update_time,salary,lower_edu,welfare,recruit_date,source) VALUES (#{companyName},#{recruitName}, #{industryName}, #{persons}, #{workPlace},#{recruitUrl}, NOW(), NOW(),#{salary},#{lowerEdu},#{welfare},#{recruitDate},#{source})")
    int insert(CompanyRecruitInfo record);

    @Update("update t_zzjob_company set contact_person = #{contactPerson},phone = #{phone},email = #{email},address = #{address} where recruit_url = #{recruitUrl}")
    int update(@Param("recruitUrl") String recruitUrl, @Param("contactPerson")String contactPerson, @Param("phone")String phone, @Param("email")String email, @Param("address")String address);

    @Insert("INSERT INTO `t_zzjob_company` (company_name,recruit_name,work_place, recruit_url,create_time,update_time,recruit_date,source) VALUES (#{companyName},#{recruitName}, #{workPlace},#{recruitUrl}, NOW(), NOW(),#{recruitDate},#{source})")
    int insertCshr(CompanyRecruitInfo record);

    @Insert("INSERT INTO `t_zzjob_company` (company_name,recruit_name,work_place,salary, recruit_url,create_time,update_time,source) VALUES (#{companyName},#{recruitName}, #{workPlace},#{salary},#{recruitUrl}, NOW(), NOW(),#{source})")
    int saveZpt(CompanyRecruitInfo record);

    @Select("SELECT t.recruit_url FROM `t_zzjob_company` t where t.source = #{source}")
    List<String> selectUrl(@Param("source")String source);

    @Update("update t_zzjob_company set lower_edu = #{lowerEdu},industry_name = #{industryName},persons = #{persons},recruit_date = #{recruitDate} where recruit_url = #{recruitUrl}")
    int updateZpt(@Param("recruitUrl") String recruitUrl, @Param("lowerEdu")String lowerEdu, @Param("industryName")String industryName, @Param("persons")String persons, @Param("recruitDate")String recruitDate);

    @Insert("INSERT INTO `t_zzjob_company` (company_name,recruit_name,salary, recruit_url,create_time,update_time,recruit_date,source) VALUES (#{companyName},#{recruitName},#{salary},#{recruitUrl}, NOW(), NOW(),#{recruitDate},#{source})")
    int savDxrc(CompanyRecruitInfo record);

    @Update("update t_zzjob_company set work_place = #{workPlace},contact_person = #{contactPerson},phone = #{phone},industry_name = #{industryName},persons = #{persons},address = #{address} where recruit_url = #{recruitUrl}")
    int updateDxrc(@Param("recruitUrl") String recruitUrl,@Param("workPlace")String workPlace, @Param("contactPerson")String contactPerson, @Param("phone")String phone, @Param("industryName")String industryName, @Param("persons")String persons, @Param("address")String address);
}
